/**
 * LaserTraq Daemon - Daniel Hiepler - (c) 2006-2007
 *
 * @defgroup main main
 * @author D.Hiepler <daniel-laser@boogiepalace.hopto.org>
 * @version VERSION
 * @{
 */
 
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <gst/gst.h>
#include <gst/interfaces/tuner.h>
#include <gst/interfaces/tunerchannel.h>
#include "include/source.h"
#include "include/x11.h"
#include "include/util.h"
#include "include/prefs.h"


int main(int argc, char *argv[])
{
    struct video_src *tmp_src;


    /*
     * initialize X 
     */
    if(x_init() < 0)
    {
        printf("Failed to initialize X stuff...\n");
        prefs_cleanup();
        return -1;
    }
    
    /* initialize preferences */
    if(prefs_init() < 0)
    {
        printf("Failed to init preferences...\n");
        return -1;
    }
    
        
        
    /*
     * parse arguments 
     */
    prefs_parse_arguments(argc, argv);
    
    /*
     * init gstreamer 
     */
    gst_init(&argc, &argv);
    
    
    /* initialize source-module */
    if(src_init() < 0)
    {
        printf("Failed to init sources...\n");
        return -1;
    }
    
    /* initialize preferences */
    if(prefs_config_init() < 0)
    {
        printf("Failed to init preferences...\n");
        return -1;
    }
    
        
   
    /*
     * main loop 
     */
    while (TRUE) {
        
        for(tmp_src = src_get(); tmp_src; tmp_src = tmp_src->next_source) 
        {
            
            _VERBOSE2 printf(" \"%s\" %d fps |", 
                                tmp_src->name, tmp_src->framecount);
            
            tmp_src->framecount = 0;
        }
        
        _VERBOSE2 printf("\n%c[F", 27);
        sleep(1);
    }

    prefs_cleanup();
    
    return 0;
}

/** 
 * @} 
 */
